import './style.css'
import GameConfig from './config';
import LoadingUI from './loading-ui';

const setup = () => {
    Laya.init(GameConfig.width, GameConfig.height, Laya['WebGL']);
    Laya.stage.scaleMode = GameConfig.scaleMode;
    Laya.stage.screenMode = GameConfig.screenMode;
    Laya.stage.alignV = GameConfig.alignV;
    Laya.stage.alignH = GameConfig.alignH;
}

const entry = () => {
    setup();
    const loadingView = new LoadingUI();
    Laya.stage.addChild(loadingView);
    //chunk
    let c = 0, t = 100;
    const fakeProgress = (cb) => {
        if (c == 100) return cb();
        c++;
        loadingView.onProgress(c, t);
        setTimeout(fakeProgress, 30, cb);
    }

    fakeProgress(() => {
        import('./entry').then(({ start }) => {
            loadingView.destroy();
            start();
        })
    });
}

entry();